Imaging With QuickDrawContentsFigures, Tables, and ListingsAbout This BookFormat of a Typical ChapterConventions Used in This BookSpecial FontsTypes of NotesEmpty StringsAssembly-Language InformationThe Development EnvironmentIntroduction to QuickDrawDrawing Environments8Figure 1-1 A grayscale image representing bits in memoryQuickDraw’s Coordinate Plane0Figure 1-2 The QuickDraw global coordinate plane9Figure 1-3 A window’s local and global coordinate systemsFigure 1-4 The coordinate planeFigure 1-5 Points and pixelsImagesFigure 1-6 Drawing a line@Figure 1-7 Lines drawn with different bit patterns and pen sizesFigure 1-8 A rectangleFigure 1-9 An ovalFigure 1-10 An arc and a wedgeFigure 1-11 A rounded rectangleFigure 1-12 A polygonFigure 1-13 Two regions&Figure 1-14 A simple QuickDraw picture.Figure 1-15 Filling and framing various shapesColorsIndexed ColorsDirect ColorsMultiple ScreensFigure 1-16 A two-screen systemCFigure 1-17 The GDevice record and pixel map for a 4-bit video card$From Memory Bits to Onscreen Pixels"Figure 1-18 The indexed-pixel path!Figure 1-19 The direct-pixel pathFrom Memory Bits to Printers8Figure 1-20 The job dialog box for a StyleWriter printer8Figure 1-21 The job dialog box for a LaserWriter printerOther Graphics ManagersBasic QuickDrawAbout Basic QuickDraw)The Mathematical Foundations of QuickDrawThe Coordinate PlanePoints
RectanglesRegions=The Black-and-White Drawing Environment: Basic Graphics Ports4Figure 2-1 The GrafPort record and the BitMap recordBitmapsFigure 2-2 A bit imagehFigure 2-3 Relationship of the boundary rectangle and the port rectangle to the global coordinate systemThe Graphics Port Drawing Area`Figure 2-4 Comparing the boundary rectangle, port rectangle, visible region, and clipping regionGraphics Port Bit PatternsThe Graphics PenText in a Graphics Port+The Limited Colors of a Basic Graphics PortOther FieldsUsing Basic QuickDrawInitializing Basic QuickDraw"Listing 2-1 Initializing QuickDrawCreating Basic Graphics PortsDListing 2-2 Using the Window Manager to create a basic graphics portSetting the Graphics Port0Listing 2-3 Saving and restoring a graphics port5Switching Between Global and Local Coordinate Systems<Listing 2-4 Changing global coordinates to local coordinates*Scrolling the Pixels in the Port Rectangle3Figure 2-5 Moving a document relative to its windowGListing 2-5 Using ScrollRect to scroll the bits displayed in the window5Figure 2-6 Updating the contents of a scrolled window{Figure 2-7 Restoring the window origin of the port rectangle to a horizontal coordinate of 0 and a vertical coordinate of 0Basic QuickDraw ReferenceData StructuresPointRectRegionBitMapGrafPortRoutinesInitializing QuickDrawInitGraf$Table 2-1 QuickDraw global variables(Opening and Closing Basic Graphics PortsOpenPort1Table 2-2 Initial values of a basic graphics portInitPort ClosePort#Saving and Restoring Graphics PortsGetPortSetPort7Managing Bitmaps, Port Rectangles, and Clipping Regions
ScrollRectOFigure 2-8 Scrolling the image in a rectangle by using the ScrollRect procedure SetOriginPortSize
MovePortToGetClipSetClipClipRectBitMapToRegionSetPortBits%Manipulating Points in Graphics PortsGlobalToLocalLocalToGlobalAddPtSubPt
DeltaPointSetPtEqualPtGetPixelSummary of Basic QuickDrawQuickDraw DrawingAbout QuickDraw DrawingThe Graphics PenFigure 3-1 A graphics penBit PatternsFigure 3-2 A bit pattern:Figure 3-3 Windows filled with the predefined bit patterns(Boolean Transfer Modes With 1-Bit Pixels:Table 3-1 Effect of Boolean transfer modes on 1-bit pixels-Figure 3-4 Examples of Boolean transfer modesLines and ShapesDefining Lines and ShapesFraming ShapesPainting and Filling ShapesErasing ShapesInverting ShapesOther Graphic Entities The Eight Basic QuickDraw ColorsDrawing With QuickDrawDrawing Lines%Figure 3-5 Using the LineTo procedure=Listing 3-1 Drawing lines with the LineTo and Line proceduresFigure 3-6 Drawing lines/Figure 3-7 Using the LineTo and Line proceduresFigure 3-8 Resizing the pen'Listing 3-2 Using the PenSize procedure?Table 3-2 The global variables for five predefined bit patterns#Figure 3-9 Changing the pen patternPListing 3-3 Using the PenPat procedure to change the pattern of the graphics penDrawing Rectangles+Figure 3-10 Two ways to specify a rectangleFigure 3-11 Drawing rectangles<Listing 3-4 Using the FrameRect procedure to draw rectangles+Figure 3-12 Painting and filling rectangles7Listing 3-5 Using the PaintRect and FillRect proceduresDrawing Ovals, Arcs, and WedgesFigure 3-13 Drawing ovals7Listing 3-6 Using the FrameOval procedure to draw ovals&Figure 3-14 Drawing an arc and a wedge6Listing 3-7 Using the FrameArc and PaintArc proceduresDrawing Regions and Polygons)Listing 3-8 Creating and drawing a region'Figure 3-15 A shape created by a regionDListing 3-9 Creating a clipping region and filling it with a pattern%Figure 3-16 Filling a clipping region*Listing 3-10 Creating a triangular polygon9Performing Calculations and Other Manipulations of ShapesHTable 3-3 QuickDraw routines for calculating and manipulating rectanglesETable 3-4 QuickDraw routines for calculating and manipulating regions#Copying Bits Between Graphics Ports3Figure 3-17 Shrinking images between graphics portsEListing 3-11 Using the CopyBits procedure to copy between two windows*Customizing QuickDraw’s Low-Level RoutinesQuickDraw Drawing ReferenceData StructuresPolygonPenStateQDProcsPatternRoutinesManaging the Graphics PenHidePenShowPenGetPenGetPenStateSetPenStatePenSizePenModePenPat PenNormal#Changing the Background Bit PatternBackPatDrawing LinesMoveToMoveLineToLine Creating and Managing RectanglesSetRect
OffsetRect InsetRectSectRect UnionRectPtInRectPt2Rect PtToAngleKFigure 3-18 Forty-five-degree angles as returned by the PtToAngle procedure EqualRect EmptyRectDrawing Rectangles FrameRect PaintRectFillRect EraseRect
InvertRectDrawing Rounded Rectangles7Figure 3-19 Oval width and height in rounded rectanglesFrameRoundRectPaintRoundRectFillRoundRectEraseRoundRectInvertRoundRectDrawing Ovals FrameOval PaintOvalFillOval EraseOval
InvertOvalDrawing Arcs and Wedges@Figure 3-20 Using angles to define the radii for arcs and wedgesFrameArcPaintArc/Figure 3-21 Using PaintArc to paint a 45° angleFillArcEraseArc InvertArcCreating and Managing PolygonsOpenPoly ClosePoly
OffsetPolyKillPolyDrawing Polygons FramePoly)Figure 3-22 Framing and painting polygons PaintPolyFillPoly ErasePoly
InvertPolyCreating and Managing RegionsNewRgnOpenRgnCloseRgn
DisposeRgnCopyRgnSetEmptyRgn
SetRectRgnRectRgn OffsetRgnInsetRgnSectRgnUnionRgnDiffRgnXorRgnPtInRgn RectInRgnEqualRgnEmptyRgnDrawing RegionsFrameRgnPaintRgnFillRgnEraseRgn InvertRgn=Scaling and Mapping Points, Rectangles, Polygons, and RegionsScalePt#Figure 3-23 Using ScalePt and MapPtMapPtMapRectMapRgnMapPoly!Calculating Black-and-White FillsSeedFillTFigure 3-24 A source image and its resulting mask produced by the SeedFill procedure?Figure 3-25 Parameters for the SeedFill and CalcMask proceduresCalcMaskTFigure 3-26 A source image and the resulting mask produced by the CalcMask procedureCopying ImagesCopyBits.Figure 3-27 Using CopyBits to stretch an imageCopyMaskCopyDeepMask#Drawing With the Eight-Color System ForeColor BackColorColorBit2Determining Whether QuickDraw Has Finished DrawingQDDoneGetting Pattern Resources
GetPatternGetIndPatternFigure 3-28 Standard patterns Customizing QuickDraw OperationsSetStdProcsStdTextStdLineStdRectStdRRectStdOvalStdArcStdPolyStdRgnStdBits
StdComment
StdTxtMeas StdGetPic StdPutPic ResourcesThe Pattern Resource:Figure 3-29 Format of a compiled pattern ('PAT ') resourceThe Pattern List Resource?Figure 3-30 Format of a compiled pattern list ('PAT#') resourceSummary of QuickDraw DrawingColor QuickDrawAbout Color QuickDraw
RGB Colors3The Color Drawing Environment: Color Graphics Ports"Figure 4-1 The color graphics port
Pixel MapsFigure 4-2 The pixel mapPixel Patterns;Color QuickDraw’s Translation of RGB Colors to Pixel Values\Figure 4-3 Translating a 48-bit RGBColor record to an 8-bit pixel value on an indexed device\Figure 4-4 Translating an 8-bit pixel value on an indexed device to a 48-bit RGBColor recordZFigure 4-5 Translating a 48-bit RGBColor record to a 32-bit pixel value on a direct deviceZFigure 4-6 Translating a 48-bit RGBColor record to a 16-bit pixel value on a direct deviceGFigure 4-7 Translating a 32-bit pixel value to a 48-bit RGBColor recordGFigure 4-8 Translating a 16-bit pixel value to a 48-bit RGBColor recordColors on Grayscale ScreensUsing Color QuickDrawInitializing Color QuickDrawCreating Color Graphics PortsDListing 4-1 Using the Window Manager to create a color graphics port(Drawing With Different Foreground Colors)Listing 4-2 Changing the foreground colorOFigure 4-9 Drawing with two different foreground colors (on a grayscale screen)Drawing With Pixel Patterns<Figure 4-10 Using ResEdit to create a pixel pattern resource2Listing 4-3 Rez input for a pixel pattern resource2Listing 4-4 Using pixel patterns to paint and fill?Figure 4-11 Painting and filling rectangles with pixel patterns+Copying Pixels Between Color Graphics Ports<Figure 4-12 Copying pixel images with the CopyBits procedure<Figure 4-13 Copying pixel images with the CopyMask procedure@Figure 4-14 Copying pixel images with the CopyDeepMask procedure(Boolean Transfer Modes With Color Pixels2Table 4-1 Boolean source modes with colored pixels8Listing 4-5 Using CopyBits to produce coloration effects DitheringArithmetic Transfer Modes1Table 4-2 Arithmetic modes in a 1-bit environmentHighlighting9Figure 4-15 Difference between highlighting and inverting%Listing 4-6 Setting the highlight bit'Listing 4-7 Using highlighting for textColor QuickDraw ReferenceData StructuresPixMap CGrafPortRGBColor ColorSpec
ColorTableMatchRecPixPatCQDProcsGrafVarsColor QuickDraw Routines(Opening and Closing Color Graphics Ports OpenCPort0Table 4-3 Initial values in the CGrafPort record InitCPort
CloseCPortManaging a Color Graphics Pen PenPixPat%Changing the Background Pixel Pattern
BackPixPat#Drawing With Color QuickDraw ColorsRGBForeColor<Table 4-4 The colors defined by the global variable QDColorsRGBBackColor SetCPixel FillCRectFillCRoundRect FillCOvalFillCArc FillCPolyFillCRgnOpColorHiliteColor7Determining Current Colors and Best Intermediate ColorsGetForeColorGetBackColor GetCPixelGetGrayCalculating Color Fills SeedCFill CalcCMask.Creating, Setting, and Disposing of Pixel Maps NewPixMap
CopyPixMap
SetPortPixDisposePixMap(Creating and Disposing of Pixel Patterns GetPixPat NewPixPat
CopyPixPat
MakeRGBPatDisposePixPat&Creating and Disposing of Color Tables GetCTableATable 4-5 The default color tables for grayscale graphics devices=Table 4-6 The default color tables for color graphics devicesDisposeCTable'Retrieving Color QuickDraw Result CodesQDError&Customizing Color QuickDraw OperationsSetStdCProcs-Reporting Data Structure Changes to QuickDrawCTabChangedPixPatChangedPortChangedGDeviceChangedApplication-Defined RoutineMyColorSearch ResourcesThe Pixel Pattern Resource@Figure 4-16 Format of a compiled pixel pattern ('ppat') resourceThe Color Table Resource>Figure 4-17 Format of a compiled color table ('clut') resourceThe Color Icon Resource=Figure 4-18 Format of a compiled color icon ('cicn') resourceSummary of Color QuickDrawGraphics DevicesAbout Graphics DevicesFigure 5-1 The GDevice recordUsing Graphics Devices5Optimizing Your Images for Different Graphics Devices*Listing 5-1 Using the DeviceLoop procedure*Listing 5-2 Drawing into different screens&Zooming Windows on Multiscreen SystemsListing 5-3 Zooming a windowSetting a Device’s Pixel Depth1Exceptional Cases When Working With Color DevicesGraphics Devices ReferenceData StructuresGDeviceDeviceLoopFlagsRoutines for Graphics Devices3Creating, Setting, and Disposing of GDevice Records
NewGDeviceInitGDeviceSetDeviceAttribute
SetGDeviceDisposeGDevice&Getting the Available Graphics Devices
GetGDeviceGetDeviceListGetMainDeviceGetMaxDeviceGetNextDevice1Determining the Characteristics of a Video Device
DeviceLoopTestDeviceAttribute ScreenRes+Changing the Pixel Depth for a Video DeviceHasDepthSetDepthApplication-Defined RoutineMyDrawingProcResourceThe Screen ResourceSummary of Graphics DevicesOffscreen Graphics WorldsAbout Offscreen Graphics WorldsUsing Offscreen Graphics Worlds$Creating an Offscreen Graphics WorldNListing 6-1 Using a single offscreen graphics world and the CopyBits procedure9Setting the Graphics Port for an Offscreen Graphics World(Drawing Into an Offscreen Graphics World(Copying an Offscreen Image Into a Window$Updating an Offscreen Graphics World?Creating a Mask and a Source Image in Offscreen Graphics WorldsJListing 6-2 Using two offscreen graphics worlds and the CopyMask procedure$Offscreen Graphics Worlds ReferenceData Structures GWorldPtrGWorldFlagsRoutines>Creating, Altering, and Disposing of Offscreen Graphics Worlds NewGWorldNewScreenBufferNewTempScreenBufferUpdateGWorldDisposeGWorldDisposeScreenBufferASaving and Restoring Graphics Ports and Offscreen Graphics Worlds GetGWorld SetGWorldGetGWorldDevice2Managing an Offscreen Graphics World’s Pixel ImageGetGWorldPixMap
LockPixelsUnlockPixelsAllowPurgePixelsNoPurgePixelsGetPixelsStateSetPixelsStateGetPixBaseAddrPixMap32Bit%Summary of Offscreen Graphics WorldsPicturesAbout Pictures#Figure 7-1 A picture of a party hatPicture FormatsFigure 7-2 The Picture record.Opcodes: Drawing Commands and Picture Comments&Color Pictures in Basic Graphics Ports;'PICT' Files, 'PICT' Resources, and the 'PICT' Scrap FormatThe Picture UtilitiesUsing PicturesCreating and Drawing Pictures*Listing 7-1 Creating and drawing a pictureFigure 7-3 A simple pictureOpening and Drawing Pictures)Drawing a Picture Stored in a 'PICT' File3Listing 7-2 Opening and drawing a picture from diskLListing 7-3 Replacing QuickDraw’s standard low-level picture-reading routineAListing 7-4 Determining whether a graphics port is color or basicIListing 7-5 A custom low-level procedure for spooling a picture from disk%Drawing a Picture Stored in the Scrap/Listing 7-6 Pasting in a picture from the scrap Defining a Destination Rectangle=Listing 7-7 Adjusting the destination rectangle for a picture-Drawing a Picture Stored in a 'PICT' Resource7Listing 7-8 Drawing a picture stored in a resource fileSaving Pictures-Listing 7-9 Saving a picture as a 'PICT' fileMListing 7-10 Replacing QuickDraw’s standard low-level picture-writing routineFListing 7-11 A custom low-level routine for spooling a picture to diskGathering Picture Information<Listing 7-12 Looking for color profile comments in a picturePictures ReferenceData StructuresPictureOpenCPicParamsCommentSpecFontSpecPictInfo(QuickDraw and Picture Utilities Routines"Creating and Disposing of PicturesOpenCPictureOpenPicture
GetPictureCollecting Picture InformationGetPictInfoGetPixMapInfoNewPictInfoRecordPictInfoRecordPixMapInfoRetrievePictInfoDisposePictInfoApplication-Defined RoutinesKTable 7-1 Routine selectors for an application-defined color-picking methodMyInitPickMethodMyRecordColorsMyCalcColorTableMyDisposeColorPickMethod ResourcesThe Picture Resource<Figure 7-4 Structure of a compiled picture ('PICT') resource!The Color-Picking Method Resource.Summary of Pictures and the Picture UtilitiesCursor UtilitiesAbout the CursorFigure 8-1 Hot spots in cursorsUsing the Cursor UtilitiesInitializing the Cursor-Listing 8-1 Initializing the Cursor Utilities%Changing the Appearance of the Cursor$Figure 8-2 The standard arrow cursorDFigure 8-3 The I-beam, crosshairs, plus sign, and wristwatch cursors4Figure 8-4 A window and its arrow and I-beam regionsIFigure 8-5 Changing the cursor from the I-beam cursor to the arrow cursorListing 8-2 Changing the cursorCreating an Animated Cursor<Figure 8-6 The 'CURS' resources for an animated globe cursor4Figure 8-7 An 'acur' resource for an animated cursor>Listing 8-3 Animating a cursor with the RotateCursor procedure<Listing 8-4 Animating a cursor with the SpinCursor procedureCursor Utilities ReferenceData StructuresBits16CursorTable 8-1 Cursor appearanceCCrsrCursorsAcurRoutinesInitializing Cursors
InitCursorInitCursorCtl Changing Black-and-White Cursors GetCursor SetCursorChanging Color Cursors
GetCCursor
SetCCursorDisposeCCursorAllocCursorHiding and Showing Cursors
SpinCursor ResourcesThe Cursor Resource8Figure 8-8 Format of a compiled cursor ('CURS') resourceThe Color Cursor Resource>Figure 8-9 Format of a compiled color cursor ('crsr') resourceThe Animated Cursor ResourceBFigure 8-10 Format of a compiled animated cursor ('acur') resourceSummary of Cursor UtilitiesPrinting ManagerAbout the Printing ManagerThe Printing Graphics Port*Getting Printing Preferences From the User2Figure 9-1 A standard File menu for an application9Figure 9-2 The style dialog box for a StyleWriter printer9Figure 9-3 The style dialog box for a LaserWriter printer7Figure 9-4 The job dialog box for a StyleWriter printer7Figure 9-5 The job dialog box for a LaserWriter printer(QuickDraw and PostScript Printer DriversPage and Paper Rectangles$Figure 9-6 Page and paper rectanglesPrinter Resolution'The TPrint Record and the Printing LoopFigure 9-7 A TPrint recordPrint Status Dialog BoxesbFigure 9-8 The print status dialog box for a LaserWriter printer driver printing in the background\Figure 9-9 A status dialog box with the LaserWriter printer driver’s print status dialog boxUsing the Printing Manager"Creating and Using a TPrint Record.Listing 9-1 Reading a document’s TPrint recordPrinting a Document"Listing 9-2 A sample printing loopPrinting From the Finder.Figure 9-10 How the PrJobMerge procedure works*Providing Names of Documents Being PrintedPrinting Hints'Getting and Setting Printer InformationXListing 9-3 Checking whether the current printer driver supports the PrGeneral procedure=Determining and Setting the Resolution of the Current PrinterOFigure 9-11 Sample resolutions for a PostScript printer and a QuickDraw printerTListing 9-4 Using the getRslDataOp and setRslOp opcodes with the PrGeneral procedureDetermining Page OrientationaListing 9-5 Using the getRotnOp opcode with the PrGeneral procedure to determine page orientation Enhancing Draft-Quality PrintingiListing 9-6 Using the draftBitsOp opcode with the PrGeneral procedure for enhanced draft-quality printing$Altering the Style or Job Dialog Box=Figure 9-12 A print job dialog box with additional checkboxesSListing 9-7 Installing an initialization function to alter the print job dialog box2Listing 9-8 Adding items to a print job dialog boxWriting an Idle ProcedureListing 9-9 An idle procedureHandling Printing ErrorsPrinting Manager ReferenceData StructuresTPrintTPrInfoTPrJobTPrStl TPrStatusTPrDlgTPrPortTGnlData
TGetRslBlk
TSetRslBlkTDftBitsBlkTGetRotnBlkPrinting Manager Routines(Opening and Closing the Printing ManagerPrOpenPrClose*Initializing and Validating TPrint RecordsPrintDefault
PrValidate1Displaying and Customizing the Print Dialog BoxesPrStlDialogPrJobDialog PrDlgMain PrStlInit PrJobInit
PrDrvrOpenPrDrvrClose PrDrvrDCE PrCtlCallTTable 9-1 Values for the lParam1 parameter when using the iPrDevCtl control constantApplication-Defined RoutinesMyDoPrintIdleMyPrDialogAppend Summary of the Printing Manager
AppendixesPicture OpcodesVersion and Header OpcodesPicture Opcode Data Types)Table A-1 Data types for picture opcodesOpcodes in Pictures?Table A-2 Opcodes for extended version 2 and version 2 picturesCListing A-1 Data for the BkPixPat, PnPixPat, and FillPixPat opcodes:Listing A-2 Data for the BitsRect and PackBitsRect opcodes8Listing A-3 Data for the BitsRgn and PackBitsRgn opcodes(Table A-3 Opcodes for version 1 pictures$A Sample Extended Version 2 Picture>Listing A-4 Creating and drawing an extended version 2 pictureFigure A-1 A picture3Listing A-5 A decompiled extended version 2 pictureA Sample Version 2 Picture*Listing A-6 A decompiled version 2 pictureA Sample Version 1 Picture*Listing A-7 A decompiled version 1 picture#Using Picture Comments for PrintingAbout Picture Comments<Table B-1 Names, values, and data sizes for picture comments Maintaining Device IndependenceNTable B-2 Low-level QuickDraw routines disabled by the PostScriptBegin comment7Synchronizing QuickDraw and PostScript Printer Drivers=Listing B-1 Synchronizing QuickDraw and the PostScript driver?Listing B-2 Flushing the buffer for a PostScript printer driverUsing Text Picture Comments$Disabling and Reenabling Line LayoutOFigure B-1 The line layout error between a bitmapped font and a PostScript font!Figure B-2 Major and minor glyphs8Figure B-3 Distributing layout error to the major glyphsAFigure B-4 Distributing layout error among major and minor glyphsDFigure B-5 Using the LineLayoutOff and LineLayoutOn picture commentsDelimiting Strings]Listing B-3 Disabling line layout by using the LineLayoutOff and StringBegin picture commentsRotating Text'Figure B-6 Variations in text alignment:Listing B-4 Displaying rotated text using picture commentsUsing Graphics Picture CommentsDrawing PolygonsFigure B-7 Types of polygonsListing B-5 Creating polygonsListing B-6 Drawing polygons,Figure B-8 QuickDraw and PostScript polygonsRotating Graphics5Listing B-7 Using picture comments to rotate graphicsOListing B-8 Using the RotateCenter, RotateBegin, and RotateEnd picture comments$Using Line-Drawing Picture CommentsDrawing Dashed Lines0Listing B-9 Using the DashedLine picture commentUsing Fractional Line WidthsHFigure B-9 Changing the pen width using the SetLineWidth picture comment3Listing B-10 Using the SetLineWidth picture comment"Using PostScript Picture Comments$Calling PostScript Routines Directly<Listing B-11 Sending PostScript code directly to the printerOptimizing PostScript PrintingPicture Comments to Avoid8Including Constants and Data Types for Picture CommentsGlossaryIndex